<?php

use yii\db\Migration;

class m170710_072837_alter_goods extends Migration
{


    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%goods}}', 'subsidy_type', $this->smallInteger(2) . ' default 1 comment \'课时补助类型（1，按学生 2 课程）\'');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%goods}}', 'subsidy_type');
        }
    }

}
